<script>
var url='<?php echo $this->getUrl()?>'
var value=0;
function calculate() {
	value= document.getElementById('sel').value;
	window.location=url+'?value='+value;
}
</script>

<?php 
 $_products=$this->getProductCollection();
?>

<?php 
if(count($_products) == 0): //if($_products->getSize()==0): 
/*
?>
		<div class="note-msg">
		<?php echo $this->__('No products sold yet. Products will be listed here after purchases are made...') ?>
		</div>
<?php 
*/
else: 
?>
<div class="box best-selling">
<h3>Best Selling Products</h3>
		
				<table border="0" cellspacing="0" width="100%">
				<tbody>
				<tr class="odd">
				<?php $_collectionSize = $_products->getSize(); echo $_collectionSize; ?>
				<?php $sameProduct = array(); $count = 0; $i=0; ?>
				<?php  foreach ($_products  as $_product): ?>			
				
                <?php $categoryIds = $_product->getData('category_ids'); ?>
				<?php $categoryIds = explode(',',$categoryIds);?>                
                <?php $categoryId  = $categoryIds[count($categoryIds)-1]; ?>
                <?php $category    = Mage::getModel('catalog/category')->load($categoryId);?>
				
				<?php
				if($i != 0 && $i%2 == 0) {
					?>
					</tr><tr class="odd">
					<?php 
				}
				?>				
					<td>
						<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
							<img class="product-img" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(95); ?>" width="95" height="95" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
						</a>
										 
						 <div class="product-description">
							<p><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName())?></a></p>
							<p><?php echo $this->getPriceHtml($_product, true) ?></p>
						</div> 
					</td>							
				<?php $i++; ?>
				<?php endforeach ?>
				</tr>
				</tbody>
				</table>
<div class="clearer"></div>
<div>
<select id="sel" name="time" onchange="javascript:calculate()" >
<option value="0"<?php if($this->getRequest()->getParam('value')==0):echo ' selected="selected" '; endif; ?>>select</option>
<option value="1" <?php if($this->getRequest()->getParam('value')==1):echo ' selected="selected" '; endif;  ?>>last month</option>
<option value="2" <?php if($this->getRequest()->getParam('value')==2):echo ' selected="selected" '; endif; ?>>last six month</option>
<option value="3" <?php if($this->getRequest()->getParam('value')==3):echo ' selected="selected" '; endif; ?>>last year</option>
</select>

</div>
</div>
<?php endif; ?>


